package com.itheima.controller;

import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.CheckGroup;
import com.itheima.service.CheckGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkgroup")
public class CheckGroupController {
    @Autowired
    private CheckGroupService checkGroupService;

    @PostMapping("/findPage.do")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
        PageResult result = checkGroupService.findPage(queryPageBean);
        return result;
    }

    @PostMapping("/add.do")
    public Result add(Integer[] checkitemIds, @RequestBody CheckGroup checkGroup) {
        Result result = checkGroupService.add(checkitemIds, checkGroup);
        return result;
    }

    @GetMapping("/findById.do")
    public Result findById(Integer id) {
        Result result = checkGroupService.findById(id);
        return result;
    }

    @GetMapping("/findCheckItemIdsByCheckGroupId.do")
    public Result findCheckItemIdsByCheckGroupId(Integer id) {
        Result result = checkGroupService.findCheckItemIdsByCheckGroupId(id);
        return result;
    }

    @PostMapping("/edit.do")
    public Result edit(Integer[] checkitemIds, @RequestBody CheckGroup checkGroup) {
        Result result = checkGroupService.modify(checkitemIds, checkGroup);
        return result;
    }

    @GetMapping("/findAll.do")
    public Result findAll() {
        Result result = checkGroupService.findAll();
        return result;
    }

    @GetMapping("/findCheckGroupIdsBySetmealId.do")
    public Result findCheckGroupIdsBySetmealId(Integer id){
        Result result = checkGroupService.findGroup(id);
        return result;
    }
}
